package com.ujoku.view.builder;

import com.labillusion.core.platform.web.rest.view.BaseViewBuilder;
import com.ujoku.domain.Country;
import com.ujoku.view.domain.CountryListView;
import com.ujoku.view.domain.CountryView;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Andy.Lian on 2015/1/25.
 */
@Component
public class CountryViewBuilder extends BaseViewBuilder<Country,CountryView> {
    public CountryListView buildCountryView(List<Country> countryList)throws Exception{
        CountryListView countryListView=new CountryListView();
        countryListView.setCountryList(new ArrayList<>());
        for (Country country:countryList){
            CountryView countryView=Create(country);
            countryListView.getCountryList().add(countryView);
        }
        return countryListView;
    }
}
